import requests
# rp=requests.get(url="http://www.baidu.com")
sess=requests.session()
IP="192.168.1.84"
#Restful-GET类型接口
def restful_get():
    rp=sess.request("get","http://"+IP+":8080/pinter/com/phone/10")
    print(rp.json())
#Restful-POST类型接口
def restful_post():
    json = {"brand":"Huawei","color":"yellow","memorySize":"64G","cpuCore":"8核","price":"8848","desc":"全新上市"}
    rp = sess.request("post","http://192.168.1.84:8080/pinter/com/phone",json=json)
    print(rp.text)
#Restful-PUT类型接口
def restful_put():
    json = {"brand":"Huawei","color":"yellow","memorySize":"64G","cpuCore":"8核","price":"8848","desc":"全新上市"}
    rp = sess.request("put","http://192.168.1.84:8080/pinter/com/phone",json=json)
    print(rp.text)

def restful_DELETE():
    json = {"brand":"Huawei","color":"yellow","memorySize":"64G","cpuCore":"8核","price":"8848","desc":"全新上市"}
    rp = sess.request("DELETE","http://192.168.1.84:8080/pinter/com/phone",json=json)
    print(rp.text)

if __name__=="__main__":
    restful_get()
    restful_post()
    restful_put()
    restful_DELETE()